using UnityEngine;
using UnityEngine.Serialization;

namespace Geo.DizzyLab
{
    public class SwingController : MonoBehaviour
    {
        public Transform target;
        public AnimationCurve rollCurve;
        public float amplitude;
        public float frequency;

        private void Update()
        {
            var roll = amplitude * rollCurve.Evaluate(Time.time*frequency);

            var euler = target.localRotation.eulerAngles;
            euler.z = roll;
            target.localRotation = Quaternion.Euler(euler);
        }

        public void SetScale(float scale)
        {
            this.amplitude = scale;
        }
    }
    
}
